<?php
include 'class/in_it.php';
login_redirect();


if(empty($_POST) === false){
    $username = $_POST['username'];
    $password = $_POST['password'];
    
    if (empty($username) === true || empty($password) === true){
        $errors[] = "You need to enter a username and password.";
    }   else if(user_exists($username) === false){
        $errors[] = "We can't find that username.";
    }   else {
        $login = login($username, $password);
        if ($login === false) {
            $errors[] = "That username/password combination is incorrect.";
        } else {
            $_SESSION['user_id'] = $login;
            header('Location: index.php');
            exit();
        }
    }
}   else{
    $errors[] = 'No data received.';
}
include 'includes/overall/header.php';
if (empty($errors) === false )
?>
<?php
include 'includes/home.php';
include 'includes/overall/footer.php';
?>